<template>
  <Page>
    <p-header title="History Orders"/>
    <ScrollView orientation="vertical">
      <StackLayout class="content">
         <order-item v-for="(item, index) in orders" v-bind:key="index" :order="item"/>
      </StackLayout>
    </ScrollView>
  </Page>
</template>
<script>
import {dataBus} from '~/business/DataBus'
import OrderItem from '~/components/common/OrderItem'
import Header from '~/components/common/Header'
export default {
  name: 'Orders',
  data() {
    return {
      orders: []
    }
  },
  props: {
    isHistory: Boolean
  },
  components: {
    'order-item': OrderItem,
    'p-header': Header,
  },
  methods: {
    onOrdersChange() {
      this.setOrders()
    },
    setOrders() {
      this.orders = this.isHistory? dataBus.orders.closed : dataBus.orders.opened
    },
  },
  mounted() {
    this.setOrders()
    dataBus.orderListener(this)
  },
  beforeDestroy() {
    dataBus.orderListener(this)
  },
}
</script>
<style scoped>
.content {
  background: #203956;
  height: auto;
}
</style>

